package com.wangwei;

import java.math.BigInteger;

public class Utils {

    /**
     * 计算数字n的阶乘
     *
     * @param seed
     * @return
     */
    public static final BigInteger arrange(int n) {
        if (n == 0) {
            return BigInteger.ONE;
        }
        BigInteger result = BigInteger.ONE;
        for (int i = 1; i <= n; i++) {
//            result *= i;
            result = result.multiply(BigInteger.valueOf(i));
        }

        return result;
    }


    public static final BigInteger compose(int n, int m) {
        BigInteger arrange1 = arrange(n);

        BigInteger arrange2 = arrange(m);
        BigInteger arrange3 = arrange(n - m);

        return arrange1.divide(arrange2.multiply(arrange3));
    }

    public static void main(String[] args) {
        System.out.println(arrange(6));

        System.out.println(compose(6, 1));
    }
}
